package observer;

import java.awt.Component;

@SuppressWarnings("serial")
public class Frame extends javax.swing.JFrame {
	Senzor senzor = new Senzor();
	
	//Creeaza o noua fereastra
	public Frame() {
		initComponents();
		senzor.addObserver((Observer)jTextField1);
		//adauga observer pt jTextField1
		senzor.addObserver((Observer) canvas1);
		//adauga observer pt canvas1
		senzor.addObserver((Observer) canvas2);
		//adauga observer pt canvas2
		senzor.addObserver((Observer) canvas3);
	}
	
	private void initComponents(){
		canvas1 = new observer.ValoareCurentaBara();
		canvas2 = new observer.ValoareCurentaHistograma();
		jTextField1 = new observer.ValoareCurenta();
		jButton1 = new javax.swing.JButton();
		canvas3 = new observer.ValoareCurentaClock();
		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		jButton1.setText("Genereaza ");
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void	actionPerformed (java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});
		
		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent((Component) canvas1,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE).addComponent((Component) canvas3,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)).addGap(45,45,45)).addGroup(layout.createSequentialGroup().addGap(38, 38, 38).addComponent((Component) jTextField1,javax.swing.GroupLayout.PREFERRED_SIZE,163,javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))).addComponent((Component) canvas2,javax.swing.GroupLayout.PREFERRED_SIZE,249,javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(56,Short.MAX_VALUE)).addGroup(layout.createSequentialGroup().addGap(69,69,69).addComponent(jButton1).addContainerGap(362, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,false).addComponent((Component) canvas2,0,0,Short.MAX_VALUE).addComponent((Component) canvas1,javax.swing.GroupLayout.DEFAULT_SIZE,132,Short.MAX_VALUE)).addGap(37,37,37).addComponent((Component) canvas3,javax.swing.GroupLayout.PREFERRED_SIZE,121, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(32,32,32).addComponent(jButton1).addGap(18,18,18).addComponent((Component) jTextField1,javax.swing.GroupLayout.PREFERRED_SIZE,29, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(75,75,75)));
		pack();
	}
	
	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		senzor.generare();
	}
	
	public static void main(String [] args) {
		java.awt.EventQueue.invokeLater(new Runnable(){
			public void run(){
				new Frame().setVisible(true);
			}
		});
	}
	
	private java.awt.Canvas canvas1;
	private java.awt.Canvas canvas2;
	private java.awt.Canvas canvas3;
	private javax.swing.JButton jButton1;
	private javax.swing.JTextField jTextField1;
}
